﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
using System.Windows.Forms.VisualStyles;

namespace ButtonTree2
{
    public static class RibbonPaintUtils
    {

        #region The new code that paint all ribbon buttons

        private static void PaintFlatStyleButton(Graphics g, Rectangle rect, bool hasMiddleLine, bool isLarge, int offsetMiddle,
            Color colorFill, Color colorBorder, Color colorLightBorder)
        {
            SmoothingMode originMode = g.SmoothingMode;
            g.SmoothingMode = SmoothingMode.AntiAlias;  // 设置绘图抗锯齿

            RibbonFlatStylePaintUtils.PaintButton(g, rect, colorFill, colorBorder, colorLightBorder);

            if (hasMiddleLine)
            {
                RibbonFlatStylePaintUtils.PaintMiddleLine(g, rect, isLarge, offsetMiddle, colorBorder, colorLightBorder);
            }

            g.SmoothingMode = originMode;
        }

        private static void PaintFlatStyleButton_Hover(Graphics g, Rectangle rect, bool hasMiddleLine, bool isLarge, int offsetMiddle)
        {
            Color colorFill = Color.FromArgb(0xFF, 0xFF, 0xDA, 0x6D);
            Color colorBorder = Color.FromArgb(0xFF, 0xC2, 0x8A, 0x30);
            Color colorLightBorder = Color.FromArgb(140, 0xFF, 0xFF, 0xFF);

            PaintFlatStyleButton(g, rect, hasMiddleLine, isLarge, offsetMiddle, colorFill, colorBorder, colorLightBorder);
        }

        private static void PaintFlatStyleButton_Hover(Graphics g, Rectangle rect)
        {
            PaintFlatStyleButton_Hover(g, rect, false, false, 0);
        }

        private static void PaintFlatStyleButton_Down(Graphics g, Rectangle rect, bool hasMiddleLine, bool isLarge, int offsetMiddle)
        {
            Color colorFill = Color.FromArgb(0xFF, 0xF0, 0xCC, 0x9B);
            Color colorBorder = Color.FromArgb(0xFF, 0xA3, 0x74, 0x28);
            Color colorLightBorder = Color.FromArgb(100, 0xFF, 0xFF, 0xFF);

            PaintFlatStyleButton(g, rect, hasMiddleLine, isLarge, offsetMiddle, colorFill, colorBorder, colorLightBorder);
        }

        private static void PaintFlatStyleButton_Down(Graphics g, Rectangle rect)
        {
            PaintFlatStyleButton_Down(g, rect, false, false, 0);
        }




        #endregion

//         // 绘制Large控件上部  鼠标悬停时
//         public static void PaintLargeButtonTop(Graphics g, Rectangle rect, bool bDrawBottomLine, bool bEnable)
//         {
//             Color colorBoundLine = bEnable ? RibbonConfigUtils.ButtonHoverBorderLineColor : RibbonConfigUtils.ButtonHoverUnableBorderLineColor;
// 
//             int radius = 4;
// 
//             //GraphicsUtils.DrawRoundRect_LeftTopRight(g, rect, radius, colorBoundLine);
// 
//             using (GraphicsPath path = GraphicsUtils.GetGraphicsPath_RoundRect_LeftTopRight(rect, radius))
//             {
//                 if (bDrawBottomLine)
//                 {
//                     // 添加下方直线
//                     path.AddLine(new Point(rect.Left, rect.Bottom), new Point(rect.Right, rect.Bottom));
// 
//                     using (Pen pen = new Pen(colorBoundLine))
//                     {
//                         g.DrawPath(pen, path);
//                     }
//                 }
//             }
//         }


        // 绘制Large控件
        public static void PaintLargeButton(Graphics g, Rectangle rect, int iMiddle, bool bDrawMidleLine, Color[] topColors,Color[] bottomColors,
            Color bottomCenterColor, Color lightBorderColor, Color darkBorderColor)
        {
            if (rect.Height <= iMiddle)
            {
                iMiddle = rect.Height / 2;
            }

            Rectangle rectTop = new Rectangle(rect.Left, rect.Top, rect.Width, iMiddle);
            Rectangle rectBottom = new Rectangle(rect.Left, rect.Top + iMiddle, rect.Width, rect.Height - iMiddle);

            // 填充上方区域
            using (LinearGradientBrush brushTop = new LinearGradientBrush(
                rectTop,
                Color.Black,
                Color.Black,
                LinearGradientMode.Vertical))
            {
                ColorBlend colorBlend = new ColorBlend();

                colorBlend.Colors = topColors;
                colorBlend.Positions = new float[] { 0.0f, 1.0f };

                brushTop.InterpolationColors = colorBlend;

                RibbonGraphicsUtils.DrawTopRoundRect(g, null, brushTop, rectTop, 4f);
            }


            // 填充下方区域
            using (GraphicsPath path = new GraphicsPath())
            {

                path.AddRectangle(rectBottom);

                using (PathGradientBrush brush = new PathGradientBrush(path))
                {
                    brush.WrapMode = WrapMode.Tile; // 一定要加这句

                    brush.CenterPoint = new Point(rectBottom.Left + rectBottom.Width / 2, rectBottom.Top + rectBottom.Height * 9 / 10);
                    brush.SurroundColors = bottomColors;
                    brush.CenterColor = bottomCenterColor;

                    RibbonGraphicsUtils.DrawBottomRoundRect(g, null, brush, rectBottom, 4f);
                }
            }

            // 绘制边框
            Pen lightPen = new Pen(lightBorderColor, 1);
            RibbonGraphicsUtils.DrawRoundRect(g, lightPen, null, new Rectangle(1, 1, rect.Width - 3, rect.Height - 3), 4f);

            int penWidth = 1;
            Pen pen = new Pen(darkBorderColor, penWidth);

            RibbonGraphicsUtils.DrawRoundRect(g, pen, null, new Rectangle(0, 0, rect.Width - penWidth, rect.Height - penWidth), 4f);

            //绘制中间线
            if (bDrawMidleLine)
            {
                g.DrawLine(lightPen, new Point(rect.Left + 1, rect.Top + iMiddle + 1), new Point(rect.Right - 2, rect.Top + iMiddle + 1));
                g.DrawLine(pen, new Point(rect.Left + 1, rect.Top + iMiddle), new Point(rect.Right - 2, rect.Top + iMiddle));
            }
        }



        public static void PaintWhenMouseHover(Graphics g, Rectangle rect, int iMiddle, bool bDrawMidleLine)
        {
            //<BandColor style="Double">
            //  <InnerBorderColor alpha="191" red="255" green="255" blue="255" />
            //  <OuterBorderColor red="231" green="202" blue="136" />
            //</BandColor>
            //<GlowColor style="NoBright">
            //  <NorthGradientBeginColor red="255" green="253" blue="235" />
            //  <NorthGradientEndColor red="254" green="240" blue="193" />
            //  <SouthGradientBeginColor red="253" green="228" blue="156" />
            //  <SouthGradientEndColor red="255" green="251" blue="222" />
//             Color[] topColors = new Color[] { Color.FromArgb(255, 255, 253, 235), Color.FromArgb(255, 254, 240, 193) };
//             Color[] bottomColors = new Color[] { Color.FromArgb(255, 253, 228, 156) };
//             Color bottomCenterColor = Color.FromArgb(255, 255, 251, 222);
// 
//             Color lightBorderColor = Color.FromArgb(191, 255, 255, 255);
//             Color darkBorderColor = Color.FromArgb(255, 231, 202, 136);
// 
//             PaintLargeButton(g, rect, iMiddle, bDrawMidleLine, topColors, bottomColors, bottomCenterColor, lightBorderColor, darkBorderColor);

            PaintFlatStyleButton_Hover(g, rect, bDrawMidleLine, true, iMiddle);
        }

        public static void PaintWhenMouseDown(Graphics g, Rectangle rect, int iMiddle, bool bDrawMidleLine)
        {
//             Color[] topColors = new Color[] { Color.FromArgb(255, 255, 253, 224), Color.FromArgb(255, 255, 211, 90) };
//             Color[] bottomColors = new Color[] { Color.FromArgb(255, 255, 215, 84) };
//             Color bottomCenterColor = Color.FromArgb(255, 255, 235, 173);
//             Color lightBorderColor = Color.FromArgb(100, 255, 255, 255);
//             Color darkBorderColor = Color.FromArgb(255, 218, 203, 151);
// 
//             PaintLargeButton(g, rect, iMiddle, bDrawMidleLine,topColors,bottomColors,bottomCenterColor,lightBorderColor,darkBorderColor);

            PaintFlatStyleButton_Down(g, rect, bDrawMidleLine, true, iMiddle);
        }


        // 绘制Large控件
//        public static void PaintWhenMouseHover(Graphics g, Rectangle rect, int iMiddle, bool bDrawMidleLine)
//        {
//            if (rect.Height <= iMiddle)
//            {
//                iMiddle = rect.Height / 2;
//            }

//            Rectangle rectTop = new Rectangle(rect.Left, rect.Top, rect.Width, iMiddle);
//            Rectangle rectBottom = new Rectangle(rect.Left, rect.Top + iMiddle, rect.Width, rect.Height - iMiddle);


//            // 填充上方区域
//            using (LinearGradientBrush brushTop = new LinearGradientBrush(
//                rectTop,
//                Color.Black,
//                Color.Black,
//                LinearGradientMode.Vertical))
//            {
//                ColorBlend colorBlend = new ColorBlend();

//                colorBlend.Colors = new Color[] { Color.FromArgb(255, 255, 253, 224), Color.FromArgb(255, 255, 211, 90) };
//                colorBlend.Positions = new float[] { 0.0f, 1.0f };

//                brushTop.InterpolationColors = colorBlend;

//                GraphicsUtils.DrawTopRoundRect(g, null, brushTop, rectTop, 4f);
//            }


//            // 填充下方区域
//            using( GraphicsPath path = new GraphicsPath() )
//            {
////                 int w = rectBottom.Width;
////                 int h = rectBottom.Height;
//// 
////                 int r = (int)Math.Sqrt(w * w + h * h);
//// 
////                 path.AddEllipse(-r + w / 2 + rectBottom.Left, -r + h / 2 + rectBottom.Top, 2 * r, 2 * r);

//                path.AddRectangle(rectBottom);

//                using (PathGradientBrush brush = new PathGradientBrush(path))
//                {
//                    brush.WrapMode = WrapMode.Tile; // 一定要加这句

//                    brush.CenterPoint = new Point(rectBottom.Left + rectBottom.Width / 2, rectBottom.Top + rectBottom.Height * 9 / 10);
//                    brush.SurroundColors = new Color[] { Color.FromArgb(255, 255, 215, 84) };
//                    brush.CenterColor = Color.FromArgb(255, 255, 235, 173);

//                    GraphicsUtils.DrawBottomRoundRect(g, null, brush, rectBottom, 4f);
//                }
//            }


////             SolidBrush brushBottom = new SolidBrush(Color.FromArgb(180, 255, 140, 30));
//// 
////             g.FillRectangle(brushTop, rectTop);
////             g.FillRectangle(brushBottom, rectBottom);


//            // 绘制边框
//            Pen lightPen = new Pen(Color.FromArgb(100, 255, 255, 255), 1);
//            GraphicsUtils.DrawRoundRect(g, lightPen, null, new Rectangle(1, 1, rect.Width - 3, rect.Height - 3), 4f);

//            int penWidth = 1;
//            Pen pen = new Pen(Color.FromArgb(255, 218, 203, 151), penWidth);

//            GraphicsUtils.DrawRoundRect(g, pen, null, new Rectangle(0, 0, rect.Width - penWidth, rect.Height - penWidth), 4f);

//            //绘制中间线
//            if (bDrawMidleLine)
//            {
//                g.DrawLine(lightPen, new Point(rect.Left + 1, rect.Top + iMiddle + 1), new Point(rect.Right - 2, rect.Top + iMiddle + 1));
//                g.DrawLine(pen, new Point(rect.Left + 1, rect.Top + iMiddle), new Point(rect.Right - 2, rect.Top + iMiddle));
//            }
//        }
        public static void PaintSmallButton(Graphics g, Rectangle rect, int iMenuAreaWidth, bool bDrawSeparateLine, Color[] topColors, 
            Color lightBorderColor, Color darkBorderColor)
        {
            // iMenuAreaWidth 从右边计算Menu的宽度

            using (LinearGradientBrush brush = new LinearGradientBrush(
                rect,
                Color.Black,
                Color.Black,
                LinearGradientMode.Vertical))
            {
                ColorBlend colorBlend = new ColorBlend();

                colorBlend.Colors = topColors;
                colorBlend.Positions = new float[] { 0.0f, 0.5f, 1.0f };

                brush.InterpolationColors = colorBlend;

                RibbonGraphicsUtils.DrawRoundRect(g, null, brush, rect, 4f);
            }

            // 绘制边框
            Pen lightPen = new Pen(lightBorderColor, 1);
            RibbonGraphicsUtils.DrawRoundRect(g, lightPen, null, new Rectangle(1, 1, rect.Width - 3, rect.Height - 3), 3f);

            int penWidth = 1;
            Pen pen = new Pen(darkBorderColor, penWidth);

            RibbonGraphicsUtils.DrawRoundRect(g, pen, null, new Rectangle(0, 0, rect.Width - penWidth, rect.Height - penWidth), 3f);

            // 绘制与右侧菜单的间隔线
            if (bDrawSeparateLine)
            {
                //                 g.DrawLine(lightPen, new Point(rect.Right - iMenuAreaWidth, rect.Top + 1),
                //                     new Point(rect.Right - iMenuAreaWidth, rect.Bottom - 2));
                g.DrawLine(pen, new Point(rect.Right - iMenuAreaWidth, rect.Top + 1),
                    new Point(rect.Right - iMenuAreaWidth, rect.Bottom - 2));
            }
        }

        public static void PaintSmallWhenMouseDown(Graphics g, Rectangle rect, int iMenuAreaWidth, bool bDrawSeparateLine)
        {
//             Color[] topColors = new Color[] { Color.FromArgb(255, 255, 253, 224), Color.FromArgb(255, 255, 211, 90), Color.FromArgb(255, 255, 253, 224) };
//             Color lightBorderColor = Color.FromArgb(191, 255, 255, 255);
//             Color darkBorderColor = Color.FromArgb(255, 218, 203, 151);
// 
//             PaintSmallButton(g, rect, iMenuAreaWidth, bDrawSeparateLine, topColors, lightBorderColor, darkBorderColor);

            PaintFlatStyleButton_Down(g, rect, bDrawSeparateLine, false, iMenuAreaWidth);
        }

        public static void PaintSmallWhenMouseHover(Graphics g, Rectangle rect, int iMenuAreaWidth, bool bDrawSeparateLine)
        {
//             Color[] topColors = new Color[] { Color.FromArgb(255, 255, 253, 235), Color.FromArgb(255, 254, 240, 193), Color.FromArgb(255, 255, 253, 235) };
// 
//             Color lightBorderColor = Color.FromArgb(191, 255, 255, 255);
//             Color darkBorderColor = Color.FromArgb(255, 231, 202, 136);
// 
//             PaintSmallButton(g, rect, iMenuAreaWidth, bDrawSeparateLine, topColors, lightBorderColor, darkBorderColor);

            PaintFlatStyleButton_Hover(g, rect, bDrawSeparateLine, false, iMenuAreaWidth);
        }
        // 绘制small控件
//        public static void PaintSmallWhenMouseHover(Graphics g, Rectangle rect, int iMenuAreaWidth, bool bDrawSeparateLine)
//        {
//            // iMenuAreaWidth 从右边计算Menu的宽度

//            using (LinearGradientBrush brush = new LinearGradientBrush(
//                rect,
//                Color.Black,
//                Color.Black,
//                LinearGradientMode.Vertical))
//            {
//                ColorBlend colorBlend = new ColorBlend();

//                colorBlend.Colors = new Color[] { Color.FromArgb(255, 255, 253, 224), Color.FromArgb(255, 255, 211, 90), Color.FromArgb(255, 255, 253, 224) };
//                colorBlend.Positions = new float[] { 0.0f, 0.5f, 1.0f };

//                brush.InterpolationColors = colorBlend;

//                GraphicsUtils.DrawRoundRect(g, null, brush, rect, 4f);
//            }

//            // 绘制边框
//            Pen lightPen = new Pen(Color.FromArgb(100, 255, 255, 255), 1);
//            GraphicsUtils.DrawRoundRect(g, lightPen, null, new Rectangle(1, 1, rect.Width - 3, rect.Height - 3), 3f);

//            int penWidth = 1;
//            Pen pen = new Pen(Color.FromArgb(255, 218, 203, 151), penWidth);

//            GraphicsUtils.DrawRoundRect(g, pen, null, new Rectangle(0, 0, rect.Width - penWidth, rect.Height - penWidth), 3f);

//            // 绘制与右侧菜单的间隔线
//            if (bDrawSeparateLine)
//            {
////                 g.DrawLine(lightPen, new Point(rect.Right - iMenuAreaWidth, rect.Top + 1),
////                     new Point(rect.Right - iMenuAreaWidth, rect.Bottom - 2));
//                g.DrawLine(pen, new Point(rect.Right - iMenuAreaWidth, rect.Top + 1),
//                    new Point(rect.Right - iMenuAreaWidth, rect.Bottom - 2));
//            }
//        }

        public static void PaintSubtransparentWhiteBottomRoundRect(Graphics g, Rectangle rect)
        {
            rect.Inflate(-1, -1);
            using(SolidBrush brush = new SolidBrush(Color.FromArgb(127, 255, 255, 255)))
            {
                RibbonGraphicsUtils.DrawBottomRoundRect(g, null, brush, rect, 4f);
            }
        }

        public static void PaintSubtransparentWhiteTopRoundRect(Graphics g, Rectangle rect)
        {
            rect.Inflate(-1, -1);
            using (SolidBrush brush = new SolidBrush(Color.FromArgb(127, 255, 255, 255)))
            {
                RibbonGraphicsUtils.DrawTopRoundRect(g, null, brush, rect, 4f);
            }
        }

        public static void PaintSubtransparentWhiteLeftRoundRect(Graphics g, Rectangle rect)
        {
            rect.Inflate(-1, -1);
            using(SolidBrush brush = new SolidBrush(Color.FromArgb(127, 255, 255, 255)))
            {
                RibbonGraphicsUtils.DrawLeftRoundRect(g, null, brush, rect, 4f);
            }
        }

        public static void PaintSubtransparentWhiteRightRoundRect(Graphics g, Rectangle rect)
        {
            rect.Inflate(-1, -1);
            using(SolidBrush brush = new SolidBrush(Color.FromArgb(127, 255, 255, 255)))
            {
                RibbonGraphicsUtils.DrawRightRoundRect(g, null, brush, rect, 4f);
            }
        }
        

        // 绘制小三角形
        public static void PaintSmallTriangle(Graphics g, Rectangle rectArea, HorizontalAlignment horAlign,
            VerticalAlignment verAlign, int width, Padding margin, Color color)
        {
            PaintSmallTriangle(g, rectArea, horAlign, verAlign, width, margin, color, true);
        }

        // 绘制小三角形 参数 isDown 表示箭头方向是否朝下
        public static void PaintSmallTriangle(Graphics g, Rectangle rectArea, HorizontalAlignment horAlign,
            VerticalAlignment verAlign, int width, Padding margin, Color color, bool isDown)
        {
            // rectArea 表示小三角最终要放置的矩形区域
            // width 表示小三角的宽度

            int height = width * 3 / 4;

            int x = 0;
            int y = 0;

            switch (horAlign)
            {
                case HorizontalAlignment.Left:
                    x = rectArea.Left + margin.Left;
                    break;
                case HorizontalAlignment.Center:
                    //x = (rectArea.Right + rectArea.Left) / 2 - width / 2;
                    x = (rectArea.Right + rectArea.Left - width) / 2;
                    break;
                case HorizontalAlignment.Right:
                    x = rectArea.Right - margin.Right - width;
                    break;
            }

            switch (verAlign)
            {
                case VerticalAlignment.Top:
                    y = rectArea.Top + margin.Top;
                    break;
                case VerticalAlignment.Center:
                    y = (rectArea.Top + rectArea.Bottom - height) / 2;
                    break;
                case VerticalAlignment.Bottom:
                    y = rectArea.Bottom - margin.Bottom - height;
                    break;
            }

            Point[] ptArr = null;

            if (isDown) // 三角 箭头方向朝下
            {
                ptArr = new Point[] { new Point(0, 0), new Point(width, 0), new Point(width / 2, height) };
            } 
            else
            {
                // 朝上
                ptArr = new Point[] { new Point(0, height), new Point(width / 2, 0), new Point(width, height) };
            }

            
            for (int i = 0; i < ptArr.Length; ++i)
            {
                ptArr[i].X += x;
                ptArr[i].Y += y;
            }

            using (GraphicsPath gp = new GraphicsPath())
            {
                gp.AddLines(ptArr);
                gp.CloseFigure();
                using (SolidBrush brush = new SolidBrush(color))
                {
                    g.FillPath(brush, gp);
                }
            }
        }

        public static void PaintNormalBackGround(Graphics g, Rectangle rect, bool isChecked)
        {
            rect = new Rectangle(rect.Left, rect.Top, rect.Width - 1, rect.Height - 1);
            if (isChecked)
            {
                using (SolidBrush brush = new SolidBrush(RibbonConfigUtils.ButtonCheckedFillColor))
                {
                    using (Pen pen = new Pen(RibbonConfigUtils.ButtonCheckedBoundColor))
                    {
                        RibbonGraphicsUtils.DrawRoundRect(g, pen, brush, rect, 4f);
                    }
                }
            }
        }

        //////////////////////////////////////////////////////////////////////////
        // Tab

        public static void PaintTab(Graphics g, Rectangle rect, string text, bool bSelected, bool bMouseHover)
        {
            if (bSelected)
            {
                // 绘制被选中选项卡

                using (SolidBrush brush = new SolidBrush(RibbonConfigUtils.TabBackLinearColor_0))
                {
                    //                     using (Pen pen = new Pen(RibbonConfigUtils.TabContorlBorderColor))
                    //                     {
                    //                         GraphicsUtils.DrawTopRoundRect(g, pen, brush, rect, 4f);
                    //                     }

                    RibbonGraphicsUtils.DrawTopRoundRect(g, null, brush, rect, 4f);
                    RibbonGraphicsUtils.DrawRoundRect_LeftTopRight(g, rect, 4, RibbonConfigUtils.TabContorlBorderColor);
                }
            }

            if (bMouseHover)
            {
                // 绘制鼠标悬停效果
                //                 using (Pen pen = new Pen(RibbonConfigUtils.TabMouseHoverBorderColor, 1))
                //                 {
                //                     GraphicsUtils.DrawTopRoundRect(g, pen, null, rect, 4f);
                //                 }
                RibbonGraphicsUtils.DrawRoundRect_LeftTopRight(g, rect, 4, RibbonConfigUtils.TabMouseHoverBorderColor);


                Rectangle rectLightLine = new Rectangle(rect.Left + 1, rect.Top + 1, rect.Width - 2, rect.Height - 2);
                //                 using (Pen pen = new Pen(RibbonConfigUtils.LightLineColor, 1))
                //                 {
                //                     GraphicsUtils.DrawTopRoundRect(g, pen, null, rectLightLine, 4f);
                // 
                //                 }
                RibbonGraphicsUtils.DrawRoundRect_LeftTopRight(g, rect, 4, RibbonConfigUtils.LightLineColor);
            }

            g.DrawString(text, RibbonConfigUtils.TextNormalFont,
                new SolidBrush(RibbonConfigUtils.TextNormalColor),
                rect, RibbonConfigUtils.TextNormalStringFormat);
        }


        //-----------------------------------------------------------------------------------------
        // RibbonButton 的菜单项
        public static void PaintRibbonMenuItemBackground(Graphics g, Rectangle rect, bool isSelected)
        {
            if (isSelected)
            {
//                 float radius = 3f;
// 
//                 // 填充色
//                 using (GraphicsPath path = new GraphicsPath())
//                 {
//                     path.AddRectangle(rect);
// 
//                     using (PathGradientBrush brush = new PathGradientBrush(path))
//                     {
//                         brush.WrapMode = WrapMode.Tile; // 一定要加这句
// 
//                         brush.CenterPoint = new Point(rect.Left + rect.Width / 2, rect.Top + rect.Height);
//                         brush.SurroundColors = new Color[] { RibbonConfigUtils.ButtonHoverFillColor_1 };
//                         brush.CenterColor = RibbonConfigUtils.ButtonHoverFillColor_0;
// 
//                         GraphicsUtils.DrawRoundRect(g, null, brush, rect, radius);
//                     }
//                 }
// 
//                 // 白色亮边框
//                 using (Pen pen = new Pen(RibbonConfigUtils.ButtonWhiteBorderLineColor))
//                 {
//                     Rectangle rectWhiteBorder = new Rectangle(new Point(rect.Left + 1, rect.Top + 1), new Size(rect.Width - 2, rect.Height - 2));
//                     GraphicsUtils.DrawRoundRect(g, pen, null, rectWhiteBorder, radius);
//                 }
// 
//                 // 玻璃亮度效果
//                 using (Brush brush = new SolidBrush(RibbonConfigUtils.WhiteGlassColor))
//                 {
//                     Rectangle rectGlassWhite = new Rectangle(new Point(rect.Left, rect.Top), new Size(rect.Width, rect.Height * 2 / 5));
//                     GraphicsUtils.DrawTopRoundRect(g, null, brush, rectGlassWhite, radius);
//                 }
// 
// 
//                 // 外部边框颜色
//                 using (Pen pen = new Pen(RibbonConfigUtils.ButtonHoverBorderLineColor))
//                 {
//                     GraphicsUtils.DrawRoundRect(g, pen, null, rect, radius);
//                 }
                PaintFlatStyleButton_Hover(g, rect);
            }

        }

//         //-----------------------------------------------------------------------------------------
//         // 下拉菜单背景
//         public static void PaintRibbonToolStripBackground(Graphics g, Rectangle rect)
//         {
//             g.FillRectangle(Brushes.White, rect);
//         }
    }
}
